package cn.hfatec.shms.hr.hrInduction.service;

import java.util.List;
import java.util.HashMap;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.hfatec.base.BaseDao;
import cn.hfatec.Page;
import cn.hfatec.Table;
import cn.hfatec.shms.hr.hrInduction.model.HrInduction;
import cn.hfatec.shms.hr.hrInduction.dao.HrInductionDao;
import cn.hfatec.shms.hr.hrInduction.model.HrInductionParams;

import javax.annotation.Resource;



/**
 *
 * @author hfatec
 * @version 1.0
 *
 * the JAVA code is generate by middlegen
 *
 */
@Service("HrInductionService")
public class HrInductionService {

    public static final String BEAN_ID = "HrInductionService";

    //注入Dao层
    @Resource(name = "HrInductionDao")
    private HrInductionDao hrInductionDao;

    //注入BaseDao
    @Resource(name = "BaseDao")
    private BaseDao baseDao;

    /**
     *
     * 查询数据
     *
     * @param hrInductionParams
     * @param page
     *
     */
    @Transactional
    public Table queryHrInductionTable(HrInductionParams hrInductionParams, Page page){

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("params", hrInductionParams);
        return baseDao.queryTableByPage("queryHrInduction", params, page);
    }

    /**
     *
     * 插入数据
     * @param hrInduction
     *
     */
    @Transactional
    public void saveHrInduction(HrInduction hrInduction) {
        if(hrInduction.getId() != null) {
            HrInduction result = getHrInduction(hrInduction.getId());
            if(result != null) {
                hrInductionDao.update(hrInduction);
            } else {
                hrInductionDao.insert(hrInduction);
            }
        } else {
            hrInductionDao.insert(hrInduction);
        }
    }

    /**
     *
     * 删除数据
     * @param id
     *
     */
    @Transactional
    public void deleteHrInduction(Integer id) {

        hrInductionDao.delete(id);
    }

    /**
     *
     * 删除数据
     * @param hrInductionList
     *
     */
    @Transactional
    public void deleteHrInductionBatch(List<String> hrInductionList) {
        for(String id : hrInductionList) {
            deleteHrInduction(Integer.valueOf(id));
        }
    }

    /**
     *
     * 根据ID获取数据
     * @param id
     *
     */
    @Transactional
    public HrInduction getHrInduction(Integer id) {

        return hrInductionDao.getHrInductionById(id);
    }

    /**
     *
     * 根据ID获取数据
     * @param employeeId
     *
     */
    @Transactional
    public HrInduction getHrInduction(String employeeId) {

        return hrInductionDao.getInductionById(employeeId);
    }
}